export default {
    methods: {
        // 格式化时间  时间默认当天 格式默认年月日yyyy-MM-dd
        handleFormatDate(time, fmt = 'yyyy-MM-dd') {
            if (time === null || typeof time === 'undefined') return ''
            let date = new Date(time)
            let year = date.getFullYear()
            let month = String(date.getMonth() + 1).padStart(2, '0')
            let day = String(date.getDate()).padStart(2, '0')
            let hour = String(date.getHours()).padStart(2, '0')
            let minute = String(date.getMinutes()).padStart(2, '0')
            let second = String(date.getSeconds()).padStart(2, '0')
            if (fmt === 'yyyy-MM-dd') {
                return `${year}-${month}-${day}`
            } else if (fmt === 'yyyy-MM-dd hh:mm:ss') {
                return `${year}-${month}-${day} ${hour}:${minute}:${second}`
            } else if (fmt === 'yyyy-MM') {
                return `${year}-${month}`
            } else if (fmt === 'yyyy') {
                return `${year}`
            }
        },
    }
}